package com.example.deploysinggle.test1.common.util;


import com.example.deploysinggle.test1.common.util.dto.Functions;

/**
 * @author Administrator
 * @version 1.0
 * @description: TODO 调用函数时接口工具类
 * @date 2024/11/20 15:14
 */
public class FunctionUtil {
    public static void work(Functions.VoidFunction function){
        function.doAction();
    }
    public static <R> R work(Functions.FunctionR <R>function){
        return function.apply();
    }
    public static <T1,R> R work(Functions.Function<T1,R> function,T1 t1){
        return function.apply(t1);
    }

    public static <T1,T2,R> R work(Functions.BiFunction<T1,T2,R> function,T1 t1,T2 t2){
        return function.apply(t1, t2);
    }
    public static <T1,T2,T3,R> R work(Functions.TriFunction<T1,T2,T3,R> function,T1 t1,T2 t2,T3 t3){
        return function.apply(t1, t2, t3);
    }

    public static <T1,T2,T3,T4,R> R work(Functions.FourFunction<T1,T2,T3,T4,R> function,T1 t1,T2 t2,T3 t3,T4 t4){
        return function.apply(t1, t2, t3,t4);
    }
    public static <T1,T2,T3,T4,T5,R> R work(Functions.FiverFunction<T1,T2,T3,T4,T5,R> function,T1 t1,T2 t2,T3 t3,T4 t4,T5 t5){
        return function.apply(t1, t2, t3,t4,t5);
    }

    public static <T1,T2,T3,T4,T5,T6,R> R work(Functions.SixrFunction<T1,T2,T3,T4,T5,T6,R> function,T1 t1,T2 t2,T3 t3,T4 t4,T5 t5,T6 t6){
        return function.apply(t1, t2, t3,t4,t5,t6);
    }

    public static <T1,T2,T3,T4,T5,T6,T7,R> R work(Functions.SevenFunction<T1,T2,T3,T4,T5,T6,T7,R> function,T1 t1,T2 t2,T3 t3,T4 t4,T5 t5,T6 t6,T7 t7){
        return function.apply(t1, t2, t3,t4,t5,t6,t7);
    }

    public static <T1,T2,T3,T4,T5,T6,T7,T8,R> R work(Functions.EightrFunction<T1,T2,T3,T4,T5,T6,T7,T8,R> function,T1 t1,T2 t2,T3 t3,T4 t4,T5 t5,T6 t6,T7 t7,T8 t8){
        return function.apply(t1, t2, t3,t4,t5,t6,t7,t8);
    }

    public static <T1,T2,T3,T4,T5,T6,T7,T8,T9,R> R work(Functions.NinerFunction<T1,T2,T3,T4,T5,T6,T7,T8,T9,R> function,T1 t1,T2 t2,T3 t3,T4 t4,T5 t5,T6 t6,T7 t7,T8 t8,T9 t9){
        return function.apply(t1, t2, t3,t4,t5,t6,t7,t8,t9);
    }
}
